﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class user_notepad :Wozuji.Logic.PageLogin
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Header.Title = "足迹网 写日志";
        
        //得到访问的用户
        String strsql = "";
        try
        {


            if (Request.QueryString["uid"] != null)
            {
                strsql = "select member_t.member_private,member_id,userpost_id,userpost_title,userpost_content,'发表于:'+convert(varchar,userpost_time,20)+'&nbsp;&nbsp;'+cast(UserPost_Hit as varchar)+ '次阅读&nbsp;&nbsp;' + cast(UserPost_Replay as varchar) + '次回复' as tags from userpost_t,member_t  where member_t.member_id=userpost_t.userpost_userid and  userpost_userid=" + Convert.ToInt32(Request.QueryString["uid"].ToString()) + " order by userpost_time desc";
            }
            else
            {
                strsql = "select member_t.member_private,member_id,userpost_id,userpost_title,userpost_content,'发表于:'+convert(varchar,userpost_time,20)+'&nbsp;&nbsp;'+cast(UserPost_Hit as varchar)+ '次阅读&nbsp;&nbsp;' + cast(UserPost_Replay as varchar) + '次回复' as tags from userpost_t,member_t  where member_t.member_id=userpost_t.userpost_userid and  userpost_userid=" + Convert.ToInt32(Session["userid"].ToString())+" order by userpost_time desc";

            }
            DataSet ds = new DataSet();

            ds = Wozuji.DBUtility.DbHelperSQL.Query(strsql);

            string aa=ds.Tables[0].Rows[0]["userpost_id"].ToString().Trim();
            string bb = ds.Tables[0].Rows[0]["member_private"].ToString();

            if (!(ds.Tables[0].Rows[0]["member_private"].Equals("0"))||Session["userid"].ToString().Trim().Equals(ds.Tables[0].Rows[0]["userpost_id"].ToString().Trim()) )
            {
                //需要增加是否是好友的判断，将来写在类里面
                
                PagedDataSource objPds = new PagedDataSource();

                objPds.DataSource = ds.Tables[0].DefaultView;

                objPds.AllowPaging = true;
                objPds.PageSize = 5;
                int CurPage;
                if (Request.QueryString["Page"] != null)
                    CurPage = Convert.ToInt32(Request.QueryString["Page"]);
                else
                    CurPage = 1;

                objPds.CurrentPageIndex = CurPage - 1;
                lblCurrentPage.Text = "当前页：" + CurPage.ToString();

                if (!objPds.IsFirstPage)
                    lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);

                if (!objPds.IsLastPage)
                    lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);



                Repeater1.DataSource = objPds;
                Repeater1.DataBind();
            }
            else 
            {
                privateValues.Text = "<<用户隐私设置，您无权访问>>";
            }
           
       
        }
        catch (Exception ex)
        {
            privateValues.Text = "<<没有日志哦>>";
        }
        


    }
}
